package com.ohyes.bigbang.demo.helloworld.service;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.ohyes.bigbang.demo.helloworld.mapper.HelloWorldMapper;
import com.ohyes.bigbang.demo.model.User;

@Component
public class HelloWorldService implements IHelloWorldService {
	
	@Autowired
	HelloWorldMapper hwMapper;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ohyes.bigbang.demo.IHelloWorldService#add(com.ohyes.bigbang.demo.
	 * User)
	 */
	@Transactional
	public void add(User use) {
		hwMapper.insertUser(use);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ohyes.bigbang.demo.IHelloWorldService#update(com.ohyes.bigbang.demo
	 * .User)
	 */
	@Transactional
	public void update(User use) {
		hwMapper.updateUser(use);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ohyes.bigbang.demo.IHelloWorldService#delete(com.ohyes.bigbang.demo
	 * .User)
	 */
	@Transactional
	public void delete(User user) {
		hwMapper.deleteUser(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.ohyes.bigbang.demo.IHelloWorldService#select(int)
	 */
	public User select(int id) {
		User user = hwMapper.selectUser(id);
		return user;
	}

	public int getCount(User user) {
		int count = hwMapper.getCount(user);
		return count;
	}

	public List<HashMap<String,Object>> getList(User user) {
		List<HashMap<String,Object>> list = hwMapper.getList(user);
		return list;
	}
}
